package com.guanjia.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;

import java.text.SimpleDateFormat;
import java.util.Date;

public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        final Object createTime = getFieldValByName("createtime", metaObject);
        if (null==createTime){
            metaObject.setValue("createtime",new Date());
        }

    }

    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
